package requests

import (
	"github.com/gin-gonic/gin"
	"github.com/thedevsaddam/govalidator"
)

type PageRequest struct {
	Page string `valid:"page" form:"page"`
	Size int    `valid:"size" form:"size"`
}

func Page(data interface{}, c *gin.Context) map[string][]string {

	rules := govalidator.MapData{
		"size": []string{"numeric_between:2,100"},
	}

	messages := govalidator.MapData{
		"size": []string{
			"numeric_between:每页条数的值介于 2~100 之间",
		},
	}

	return validate(data, rules, messages)
}
